<SCRIPT language=JavaScript>
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
</SCRIPT>



<?
session_start();
include("db.php");
if(!isset($_POST['char']) AND isset($_SESSION['login'])){
	echo "<script>window.location='pontos.php'</script>";
}
else if(!isset($_SESSION['login'])){
	echo "<script>window.location='home.php'</script>";
}
else{
	$login=$_SESSION['login'];
	$char=$_POST['char'];
	$points=mssql_query("SELECT LevelUpPoint FROM Character WHERE AccountID='$login' AND Name='$char'"); 
	$pontos = mssql_result($points, 0, 0);
	$forca=mssql_query("SELECT Strength FROM Character WHERE AccountID='$login' AND Name='$char'");
	$forca = mssql_result($forca, 0, 0);
	$agilidade=mssql_query("SELECT Dexterity FROM Character WHERE AccountID='$login' AND Name='$char'");
	$agilidade = mssql_result($agilidade, 0, 0);
	$vitalidade=mssql_query("SELECT Vitality FROM Character WHERE AccountID='$login' AND Name='$char'");
	$vitalidade = mssql_result($vitalidade, 0, 0);
	$energia=mssql_query("SELECT Energy FROM Character WHERE AccountID='$login' AND Name='$char'");
	$energia = mssql_result($energia, 0, 0);
}
if(isset($_POST['forca'])){ 
$strength=$_POST['forca'];
$agility=$_POST['agilidade'];
$vitality=$_POST['vitalidade'];
$energy=$_POST['energia'];
$total=$strength+$agility+$vitality+$energy;
$sqlon = mssql_query("SELECT * FROM MEMB_STAT WHERE ConnectStat = 1 AND memb___id='$login'");
$online=mssql_num_rows($sqlon);

if($online>0){
echo "<script>alert('Sua conta esta conectada! saia para poder distribuir');window.location='pontos.php'</script>";
}

if($total>$pontos){
echo "<script>alert('Pontos exedeu o total!');window.location='pontos.php'</script>";
}

else{ 
$query=mssql_query("UPDATE Character
SET Strength = Strength + '$strength' ,
Dexterity = Dexterity + '$agility' ,
Vitality = Vitality + '$vitality' ,
Energy = Energy + '$energy' ,
LevelUpPoint = LevelUpPoint - $total
WHERE AccountID = '$login'
AND Name = '$char'");
echo "<script>alert('Pontos adicionados com sucesso!');window.location='pontos.php'</script>";
}
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
/* Hyperlink */
a:link {	color: #FFFFFF;	text-decoration: none;}
a:visited {	color: #FFFFFF; text-decoration: none;}
a:hover {	color: orange; text-decoration: underline;}
a:active {	color: #FFFFFF; text-decoration: none;}
.camposs {	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	background-color: #999999;
	border: 1px solid #666666;
}
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #ffffff;
	font-size: 12px;
}
body {
  scrollbar-arrow-color: #FF9900;
  scrollbar-3dlight-color: #FFFFFF;
  scrollbar-highlight-color: #000000;
  scrollbar-face-color: #FFFFFF;
  scrollbar-shadow-color: #000000;
  scrollbar-darkshadow-color: #FFFFFF;
  scrollbar-track-color: #cdcdcd;
	background-color: #000000;
}
.style1 {
	color: #000000;
	font-weight: bold;
}
.style2 {color: #000000}
-->
</style>
<body background=images/fundo2.JPG>
<script>
function send(){
	erro='';
	if(document.form1.forca.value==''){document.form1.forca.value=0}
	if(document.form1.agilidade.value==''){document.form1.agilidade.value=0}
	if(document.form1.vitalidade.value==''){document.form1.vitalidade.value=0}
	if(document.form1.energia.value==''){document.form1.energia.value=0}
	
	if(document.form1.forca.value<0){document.form1.forca.value=0; erro+=1 }
	if(document.form1.agilidade.value<0){document.form1.agilidade.value=0; erro+=1 }
	if(document.form1.vitalidade.value<0){document.form1.vitalidade.value=0; erro+=1 }
	if(document.form1.energia.value<0){document.form1.energia.value=0; erro+=1 }
	if(erro!=''){ alert('Nao use sinais nos campos') }
	document.form1.submit();
}
</script>
<div align="center">
  <form name="form1" method="post" action="" target=main>
  <table width="80%" border="1" align="center" bordercolor="#CCCCCC">
    <tr bordercolor="#000000">
      <td bordercolor="#CCCCCC"><span class="style1">Total:</span></td>
      <td bordercolor="#CCCCCC"><span class="style2"><? echo $pontos; ?></span></td>
    </tr>
    <tr bordercolor="#000000">
      <td width="70%"><span class="style2">Forca: <? echo "<font color=red>$forca"; ?></span></td>
      <td width="30%"><input type="text" name="forca" class=camposs></td>
    </tr>
    <tr bordercolor="#000000">
      <td><span class="style2">Agilidade: <? echo "<font color=red>$agilidade"; ?></span></td>
      <td><input type="text" name="agilidade" class=camposs>
      </td>
    </tr>
    <tr bordercolor="#000000">
      <td><span class="style2">Vitalidade: <? echo "<font color=red>$vitalidade"; ?></span></td>
      <td><input type="text" name="vitalidade" class=camposs>
      </td>
    </tr>
    <tr bordercolor="#000000">
      <td height="22"><span class="style2">Energia: <? echo "<font color=red>$energia"; ?></span></td>
      <td><input type="text" name="energia" class=camposs></td>
      <input type="hidden" name="char" class=camposs value=<? echo $char; ?>>
      
    </tr>
    <tr bordercolor="#000000">
      <td height="28" bordercolor="#CCCCCC">&nbsp;</td>
      <td bordercolor="#CCCCCC"><div align="right">
        <input type="submit" name="Submit" value="Pronto" class=camposs onclick"send()">
      </div></td>
    </tr>
  </table>
  </form>


<SCRIPT language=JavaScript>
<!-- Início
function DOit() {
var userinput = document.calc.input.value;
document.calc.input.value = eval(userinput);
}

function plus() {
document.calc.input.value += '+';
}

function minus() {
document.calc.input.value += '-';
}

function mult() {
document.calc.input.value += '*';
}

function div() {
document.calc.input.value += '/';
}

function decimal() {
document.calc.input.value += '.';
}

function openp() {
document.calc.input.value += '(';
}

function closep() {
document.calc.input.value += ')';
}

function num(x) {
document.calc.input.value += x;
}

function recip() {
document.calc.input.value = 1/(document.calc.input.value);
}

function square() {
document.calc.input.value = (document.calc.input.value)*(document.calc.input.value);
}

function cube() {
document.calc.input.value = (document.calc.input.value)*(document.calc.input.value)*(document.calc.input.value);
}

function pi() {
document.calc.input.value += Math.PI;
}

function plus_or_minus() {
document.calc.input.value *= -1;
}

function percent() {
document.calc.input.value *= .01;
}

function sqrt() {
document.calc.input.value = Math.sqrt(document.calc.input.value);
}

function power() {
var np = prompt("What power do you want? Must be a number!","")
document.calc.input.value = Math.pow(document.calc.input.value, np);
}

function cos() {
document.calc.input.value = Math.cos(document.calc.input.value);
}

function sin() {
document.calc.input.value = Math.sin(document.calc.input.value);
}

function tan() {
document.calc.input.value = Math.tan(document.calc.input.value);
}

function Round() {
document.calc.input.value = parseInt(document.calc.input.value);
}

//  Fim -->

</SCRIPT>
<FORM name=calc>

<TABLE height=65 cellSpacing=2 cellPadding=2 width=75 border=1>


  <TR>
    <TD align=center colspan=2><span class="style2"><font face=arial size=2><b>Calculadora de Pontos</b></font></span></td>
  </TR>
  <TR>
    <TD colspan=2 align=center><INPUT size=25 class=disp maxLength=30 name=input> </td>
  </TR>
  <TR>
    <TD align=center><INPUT class=btsblue onclick=num(1) type=button value="  1  "> <INPUT class=btsblue onclick=num(2) type=button value="  2  "> <INPUT class=btsblue onclick=num(3) type=button value="  3  "> </td>
    <TD align=center><INPUT class=btswhite onclick=plus() type=button value="  +  "> </td>
  </TR>
  <TR>
    <TD align=center><INPUT class=btsblue onclick=num(4) type=button value="  4  "> <INPUT class=btsblue onclick=num(5) type=button value="  5  "> <INPUT class=btsblue onclick=num(6) type=button value="  6  ">  </td>
    <TD align=center><INPUT class=btswhite onclick=minus() type=button value="  -  "> </td>
  </TR>
  <TR>
    <TD align=center><INPUT class=btsblue onclick=num(7) type=button value="  7  "> <INPUT class=btsblue onclick=num(8) type=button value="  8  "> <INPUT class=btsblue onclick=num(9) type=button value="  9  ">  </td>
    <TD align=center><INPUT class=btswhite onclick=mult() type=button value="  x  "> </td>
  </TR>
  <TR>
    <TD align=center> <INPUT class=btsred onclick=DOit() type=button value="  =  "> <INPUT class=btsblue onclick=num(0) type=button value="  0  ">  <INPUT class=btswhite onclick="document.calc.input.value = ''; " type=button value="  C  "></td>
    <TD align=center><INPUT class=btswhite onclick=div() type=button value="  ÷  "> </td>
</TR>
</TABLE>
</FORM>





</div>
